#include "netcal.hpp"
#include "protocol.hpp"
#include "tcpserver.hpp"
#include "daemon.hpp"
int main(int agrc, char *argv[])
{
    if (agrc != 2)
    {
        std::cout << "err usage : " << argv[0] << " port" << std::endl;
        exit(1);
    }
    int port = std::stoi(argv[1]);
    // daemon(1,0);// 不修改工作路径 输入输出重定向
    Daemon();
    ENABLEFILE();
    NetCal cal;
    std::unique_ptr<Protocol> pro = std::make_unique<Protocol>([&cal](Request &res) -> Responce
                                                               { return cal.Handler(res); });
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port, [&pro](std::shared_ptr<Socket> fd, InetAddr &client)
                                                                  { pro->GetRequest(fd, client); });
    tsvr->Start();
    return 0;
}